package com.ruoyi.web.vendorclass.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.vendorclass.domain.Vendorclass;
import com.ruoyi.web.vendorclass.service.IVendorclassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * vendorclassController
 * 
 * @author ruoyi
 * @date 2024-09-27
 */
@RestController
@RequestMapping("/vendorclass/vendorclass")
public class VendorclassController extends BaseController
{
    @Autowired
    private IVendorclassService vendorclassService;

    /**
     * 查询vendorclass列表
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(Vendorclass vendorclass)
    {
        startPage();
        List<Vendorclass> list = vendorclassService.selectVendorclassList(vendorclass);
        return getDataTable(list);
    }

    /**
     * 导出vendorclass列表
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:export')")
    @Log(title = "vendorclass", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vendorclass vendorclass)
    {
        List<Vendorclass> list = vendorclassService.selectVendorclassList(vendorclass);
        ExcelUtil<Vendorclass> util = new ExcelUtil<Vendorclass>(Vendorclass.class);
        util.exportExcel(response, list, "vendorclass数据");
    }

    /**
     * 获取vendorclass详细信息
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:query')")
    @GetMapping(value = "/{cVCCode}")
    public AjaxResult getInfo(@PathVariable("cVCCode") String cVCCode)
    {
        return success(vendorclassService.selectVendorclassByCVCCode(cVCCode));
    }

    /**
     * 新增vendorclass
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:add')")
    @Log(title = "vendorclass", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Vendorclass vendorclass)
    {
        return toAjax(vendorclassService.insertVendorclass(vendorclass));
    }

    /**
     * 修改vendorclass
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:edit')")
    @Log(title = "vendorclass", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Vendorclass vendorclass)
    {
        return toAjax(vendorclassService.updateVendorclass(vendorclass));
    }

    /**
     * 删除vendorclass
     */
    @PreAuthorize("@ss.hasPermi('vendorclass:vendorclass:remove')")
    @Log(title = "vendorclass", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cVCCodes}")
    public AjaxResult remove(@PathVariable String[] cVCCodes)
    {
        return toAjax(vendorclassService.deleteVendorclassByCVCCodes(cVCCodes));
    }
}
